import Dexie from 'dexie';

const db = new Dexie('viscometer');

db.version(1).stores({
    user: '++id, &name, password, role, showName',
    serialDevice: 'id',
    measuredata:'++id,sample,username,createTime,createOn',
    programdata:'++id,sample,username,createTime,createOn',
    model:'id,name'

});

db.on("populate", function() {
    // Init your DB with some default statuses:
    db.user.add({name: "admin", "password":"8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918","role":"ADMIN", "showName": "ADMIN"});
    db.user.add({name: "nianduji", "password":"d8fb23e4517567a725cb4a94b7ae9b699453b6a3ea8fb6daaef8049b68733a37","role":"USER", "showName": "DEFAULT USER"});
    db.user.add({name: "superAdmin", "password":"d8fb23e4517567a725cb4a94b7ae9b699453b6a3ea8fb6daaef8049b68733a37","role":"SUPPERADMIN", "showName": "DEFAULT USER"});

    db.serialDevice.add({id: 1, name: "com1"});
    db.model.add({id: 1, name: ""});


});

export default db;
